<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/15 9:04
 * Desc: 订单数据统计
 */
class Listener_Order_StatusChanged_Statistic extends Listener_Base
{
    public function handle($args)
    {
        $self       = new self();
        $self->args = $args;
        //判断队列是否开启,如果开启则把任务推送到队列
        if ($self->queue_status) {
            Queue::in('default', Listener_Order_StatusChanged_Statistic::class, $args);
        } else {
            $self->perform();
        }
    }

    /**
     * 队列任务
     * @param $args
     * User: netman
     * Date: 2023/7/17 17:39
     */
    public function perform()
    {
        $order = $this->args['order'] ?? $this->args;
        try {
            Model_Member_Order_statistic::order_statistic($order['typeid'], $order['productautoid']);
        } catch (Exception $e) {

        }
        St_Log::write('订单统计', array('ordersn' => $order['ordersn']), 'event/order_changed/log');
    }

}